package com.pc.auth.utils;

import net.sf.json.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

/**
 * @Author: lijunwei
 * @Time: 2018/6/25 0:16
 */
public class AuthUtil {
    public static final String APPID = "wx0c780653438844da";
    public static final String APPSECRET = "284c5f2c319525fa07ea831b35db62b3";

    public static JSONObject doGetJson(String url) throws IOException {
        JSONObject jsonObject = null;
        DefaultHttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(url);

        HttpResponse response = client.execute(httpGet);
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            String s = EntityUtils.toString(entity);
            jsonObject = JSONObject.fromObject(s);
        }
        httpGet.releaseConnection();
        return jsonObject;

    }

}
